Change in openvpn[master]: adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
A message that is not in the archive (sent off-list or not yet received): gerrit.1704798536000.Iaef904ee2448dc0b9ad396d3ad9ae21b9dd6281e@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/492?usp=email
to review the following change.
Change subject: adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
......................................................................
adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
In error cases cipher_kt_block_size can return 0. This would lead to a divison by zero in round_down_uint. By reordering the conditional we can make sure we only take this path if we have a valid cipher to begin with.
---
M src/openvpn/mss.c
1 file changed, 4 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/492/1
src/openvpn/mss.c +4 -7
@@ -210,13 +210,7 @@static inline size_t adjust_payload_max_cbc (const struct key_type *kt,size_t target) { -if (!cipher_kt_mode_cbc (kt->cipher)) - { -/* With stream ciphers (or block cipher in stream modes like CFB, AEAD) -* we can just use the target as is */ -return target; - } -else +if (cipher_kt_mode_cbc (kt->cipher)) {/* With CBC we need at least one extra byte for padding and then need * to ensure that the resulting CBC ciphertext length, which is always
@@ -225,6 +219,9 @@ target =round_down_size (target, block_size);return target -1 ; } +/* With stream ciphers (or block cipher in stream modes like CFB, AEAD) +* we can just use the target as is */ +return target; } static size_t
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/492?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iaef904ee2448dc0b9ad396d3ad9ae21b9dd6281e
Gerrit-Change-Number: 492
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/492?usp=email )
Change subject: adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
But this does not really change anything. It just flips the if around. Is this fooling Coverity?
And the assumption is that somehow cipher_kt_block_size could return 0 which is not something that happens for a valid cipher.
Signature · 16 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/492?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Iaef904ee2448dc0b9ad396d3ad9ae21b9dd6281e Gerrit-Change-Number: 492 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]> Gerrit-Attention: flichtenheld <[email protected]...> Gerrit-Comment-Date: Tue, 09 Jan 2024 11:24:30 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/492?usp=email )
Change subject: adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Quoted 1 line
But this does not really change anything. It just flips the if around. Is this fooling Coverity? […]
Hmm, somehow this change made sense to me earlier. But now I can't defend it anymore.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/492?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iaef904ee2448dc0b9ad396d3ad9ae21b9dd6281e
Gerrit-Change-Number: 492
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 12:29:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Gerrit-MessageType: comment
flichtenheld has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/492?usp=email )
Change subject: adjust_payload_max_cbc: Fix Coverity issue "Division or modulo by zero"
......................................................................
Abandoned
Cosmetic change only
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/492?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iaef904ee2448dc0b9ad396d3ad9ae21b9dd6281e
Gerrit-Change-Number: 492
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon